<?php
/*
后台接口
*/

// 登录认证
use Tymon\JWTAuth\Facades\JWTFactory;

$router->post('auth/login', 'Auth\AuthController@postLogin');
$router->get('auth/logout', 'Auth\AuthController@getLogout');

//需要后台认证，授权验证的接口
$router->group(['middleware' => ['Authenticate', /*'Authorize'*/]], function () use ($router) {

    $router->get('/index', function () {
        return 'hello world';
    });

    //角色管理
    $router->get('role',['uses' => 'RoleController@index','as' => 'backend.role.index']);//角色列表
    $router->post('role',['uses' => 'RoleController@store','as' => 'backend.role.store']);//增加角色
    $router->get('role/{id}',['uses' => 'RoleController@show','as' => 'backend.role.show']);//角色详情
    $router->put('role/{id}',['uses' => 'RoleController@update','as' => 'backend.role.update']);//修改角色
    $router->delete('role/{id}',['uses' => 'RoleController@destroy','as' => 'backend.role.destroy']);//删除角色
    $router->get('role/permission/{id}',['uses' => 'RoleController@permission','as' => 'backend.role.permission']);//根据角色获取权限-分组
    $router->put('role/associate-permission/{id}',['uses' => 'RoleController@associatePermission','as' => 'backend.role.associate.permission']);//角色赋权

    $router->get('role/permission_role/{id}',['uses' => 'RoleController@permission_role','as' => 'backend.role.permission_role']);//根据角色获取权限-不分组




    //权限管理
    $router->get('permission',['uses' => 'PermissionController@index','as' => 'backend.permission.index']);//权限列表
    $router->post('permission',['uses' => 'PermissionController@store','as' => 'backend.permission.store']);//增加权限
    $router->get('permission/{id}',['uses' => 'PermissionController@show','as' => 'backend.permission.show']);//权限详情
    $router->put('permission/{id}',['uses' => 'PermissionController@update','as' => 'backend.permission.update']);//修改权限
    $router->delete('permission/{id}',['uses' => 'PermissionController@destroy','as' => 'backend.permission.destroy']);//删除权限

    //操作管理
    $router->get('action/all',['uses' => 'ActionController@all','as' => 'backend.action.all']);//所有路由操作
    $router->get('action',['uses' => 'ActionController@index','as' => 'backend.action.index']);//操作列表
    $router->post('action',['uses' => 'ActionController@store','as' => 'backend.action.store']);//增加操作
    $router->get('action/{id}',['uses' => 'ActionController@show','as' => 'backend.action.show']);//操作详情
    $router->put('action/{id}',['uses' => 'ActionController@update','as' => 'backend.action.update']);//修改操作
    $router->delete('action/{id}',['uses' => 'ActionController@destroy','as' => 'backend.action.destroy']);//删除操作
    $router->post('action_per',['uses' => 'ActionController@action_per','as' => 'backend.action.action_per']);//操作权限

    //菜单管理
    $router->get('menu',['uses' => 'MenuController@index','as' => 'backend.menu.index']);//菜单列表
    $router->post('menu',['uses' => 'MenuController@store','as' => 'backend.menu.store']);//增加菜单
    $router->get('menu/checkRoute',['uses' => 'MenuController@checkRoute','as' => 'backend.menu.update']);//检测路由是否可添加
    $router->get('menu/{id}',['uses' => 'MenuController@show','as' => 'backend.menu.show']);//菜单详情
    $router->put('menu/{id}',['uses' => 'MenuController@update','as' => 'backend.menu.update']);//修改菜单
    $router->delete('menu/{id}',['uses' => 'MenuController@destroy','as' => 'backend.menu.destroy']);//删除菜单
    $router->get('menu_all',['uses' => 'MenuController@menu_all','as' => 'backend.menu.menu_all']);//菜单列表
    $router->get('menu_per',['uses' => 'MenuController@menu_per','as' => 'backend.menu.menu_per']);//菜单权限


    //后台管理员用户管理
    $router->get('admin/menus',['uses' => 'AdminUserController@menus','as' => 'backend.admin.menus']);//管理员菜单
    $router->get('admin',['uses' => 'AdminUserController@index','as' => 'backend.admin.index']);//管理员列表
    $router->post('admin',['uses' => 'AdminUserController@store','as' => 'backend.admin.store']);//增加管理员
    $router->get('admin/{id}',['uses' => 'AdminUserController@show','as' => 'backend.admin.show']);//管理员详情
    $router->put('admin/{id}',['uses' => 'AdminUserController@update','as' => 'backend.admin.update']);//修改管理员
    $router->delete('admin/{id}',['uses' => 'AdminUserController@destroy','as' => 'backend.admin.destroy']);//删除管理员    

    // 考察预约管理
    $router->group(['namespace' => 'GuestBook'], function () use ($router) {
        $router->get('guestbook',['uses' => 'GuestBookController@index','as' => 'backend.guestbook.index']);//考察预约管理列表
        $router->get('guestbook/{id}',['uses' => 'GuestBookController@show','as' => 'backend.guestbook.show']);//考察预约管理查看
    });
});

// 服务订单管理
$router->group(['namespace' => 'Service'], function () use ($router) {
    
    $router->get('service/orders',['uses' => 'ServiceOrderController@index','as' => 'backend.service.index']);// 服务订单管理
    
});

// 用户管理
$router->group(['namespace' => 'User'], function () use ($router) {
    //基础用户管理
    $router->get('user', ['uses' => 'UserController@index','as' => 'backend.user.index']);//用户列表
    $router->get('user/{user_id}', ['uses' => 'UserController@show','as' => 'backend.user.show']);//单个用户详细信息
    $router->put('user/{user_id}', ['uses' => 'UserController@update','as' => 'backend.user.update']);//用户信息修改

    //认证用户管理
    $router->get('authentication', ['uses' => 'AuthenticationController@index','as' => 'backend.authentication.index']);//认证信息列表

    //公司管理
    $router->put('company/{id}', ['uses' => 'CompanyController@update','as' => 'backend.company.update']);//公司信息修改


});

// 订单管理
$router->group(['namespace' => 'Orders', 'prefix' => 'orders'], function () use ($router) {
    $router->get('/', ['uses' => 'OrdersController@index', 'as' => 'backend.orders.index']);    //订单列表
    $router->get('/{order_id}', ['uses' => 'OrdersController@show', 'as' => 'backend.orders.show']);    //订单详情
    $router->post('/', ['uses' => 'OrdersController@store', 'as' => 'backend.orders.store']);   //创建订单
    $router->put('/{order_id}', ['uses' => 'OrdersController@update', 'as' => 'backend.orders.update']);    //更新订单：包括全量更新及部分更新
    $router->delete('/{order_id}', ['uses' => 'OrdersController@delete', 'as' => 'backend.orders.delete']); //删除订单
});

//店铺
$router->group(['prefix' => 'shop', 'namespace' => 'Shop'], function ($router) {
    $router->get('/', ['as' => 'backend.shop.index', 'uses' => 'ShopController@index']);//店铺列表
    $router->get('/enable/{sp_id}', ['as' => 'backend.shop.update', 'uses' => 'ShopController@update']);//店铺禁用、启用
    $router->get('/type', ['as' => 'backend.shop.type', 'uses' => 'ShopTypeController@index']);//店铺类型
    $router->post('/type/add', [ 'as' => 'backend.shop.type.create','uses' => 'ShopTypeController@create']);//创建店铺类型
    $router->put('/type/{id}', [ 'as' => 'backend.shop.type.update',  'uses' => 'ShopTypeController@update']);//更新店铺类型
    $router->delete('/type/{id}', [ 'as' => 'backend.shop.type.delete','uses' => 'ShopTypeController@delete']);//删除店铺类型
    $router->put('/recommend/{id}', ['uses' => 'ShopController@recommend', 'as' => 'backend.shop.recommend']);    //店铺推荐


    $router->get('/level', ['as' => 'backend.shop.level.index', 'uses' => 'ShopLevelController@index']);//店铺等级列表
    $router->post('/level/add', [ 'as' => 'backend.shop.level.create','uses' => 'ShopLevelController@create']);//创建店铺等级
    $router->put('/level/{id}', [ 'as' => 'backend.shop.level.update',  'uses' => 'ShopLevelController@update']);//更新店铺等级
    $router->delete('/level/{id}', [ 'as' => 'backend.shop.level.delete','uses' => 'ShopLevelController@delete']);//删除店铺等级
});
// 订单评论模块
$router->group(['namespace' => 'Orders', 'prefix' => 'product_comments'], function () use ($router) {
    $router->get('/', ['uses' => 'OrderProductCommentController@index', 'as' => 'backend.order_product_comment.index']);    //商品评论列表
    $router->put('/{comment_id}', ['uses' => 'OrderProductCommentController@update', 'as' => 'backend.order_product_comment.update']);    //更新评论状态
});
// 商品模块
$router->group(['prefix' => 'product', 'namespace' => 'Product'], function ($router) {
    //产品
    $router->get('/', ['as' => 'backend.product.index','uses' => 'ProductController@index']);
    $router->get('/{id:[0-9]+}', ['as' => 'backend.product.show','uses' => 'ProductController@show']);
    $router->post('/', ['as' => 'backend.product.create','uses' => 'ProductController@create']);
    $router->put('/{id}', [ 'as' => 'backend.product.update','uses' => 'ProductController@update' ]);
    $router->delete('/{id}', ['as' => 'backend.product.delete', 'uses' => 'ProductController@delete']);
    $router->post('/recommend/{id}', ['as' => 'backend.product.recommend', 'uses' => 'ProductController@recommend']);
    $router->post('/batchstatus', ['uses' => 'ProductController@batchStatus', 'as' => 'backend.product.batchStatus']);
    
    //品牌
    $router->get('/brand', ['as' => 'backend.product.brand.index','uses' => 'BrandController@index']);
    $router->get('/brand/{id}', [ 'as' => 'backend.product.brand.show', 'uses' => 'BrandController@show']);
    $router->post('/brand', [ 'as' => 'backend.product.brand.create','uses' => 'BrandController@create']);
    $router->put('/brand/{id}', [ 'as' => 'backend.product.brand.update',  'uses' => 'BrandController@update']);
    $router->delete('/brand/{id}', ['as' => 'backend.product.brand.delete', 'uses' => 'BrandController@delete']);
    
    //分类
    $router->get('/cate', [  'as' => 'backend.product.cate.index', 'uses' => 'CategoryController@index']);
    $router->get('/cate/{id}', [  'as' => 'backend.product.cate.show',   'uses' => 'CategoryController@show' ]);
    $router->post('/cate', [ 'as' => 'backend.product.cate.create', 'uses' => 'CategoryController@create' ]);
    $router->put('/cate/{id}', ['as' => 'backend.product.cate.update', 'uses' => 'CategoryController@update' ]);
    $router->delete('/cate/{id}', [ 'as' => 'backend.product.cate.delete',  'uses' => 'CategoryController@delete' ]);
    $router->post('/cate/recommend/{id}', [ 'as' => 'backend.product.cate.recommend',  'uses' => 'CategoryController@recommend' ]);
    $router->post('/cate/shopindex_recommend/{id}', [ 'as' => 'backend.product.cate.shopindex_recommend',  'uses' => 'CategoryController@shopindex_recommend' ]);
    $router->post('/cate/showstatus/{id}', [ 'as' => 'backend.product.cate.showstatus',  'uses' => 'CategoryController@showstatus' ]);
    
    //属性
    $router->get('/attr', [  'as' => 'backend.product.attr.index','uses' => 'AttributeController@index' ]);
    $router->get('/attr/{id}', [   'as' => 'backend.product.attr.show',   'uses' => 'AttributeController@show']);
    $router->post('/attr', [  'as' => 'backend.product.attr.create',    'uses' => 'AttributeController@create']);
    $router->put('/attr/{id}', [      'as' => 'backend.product.attr.update',    'uses' => 'AttributeController@update' ]);
    $router->delete('/attr/{id}', [ 'as' => 'backend.product.attr.delete',   'uses' => 'AttributeController@delete']);
    
    //属性值
    $router->get('/attr_value', [  'as' => 'backend.product.attrval.index',   'uses' => 'AttributeValueController@index']);
    $router->get('/attr_value/{id}', [   'as' => 'backend.product.attrval.show',   'uses' => 'AttributeValueController@show' ]);
    $router->post('/attr_value', [  'as' => 'backend.product.attrval.create',   'uses' => 'AttributeValueController@create']);
    $router->put('/attr_value/{id}', [   'as' => 'backend.product.attrval.update',   'uses' => 'AttributeValueController@update']);
    $router->delete('/attr_value/{id}', [  'as' => 'backend.product.attrval.delete',   'uses' => 'AttributeValueController@delete']);
    
    $router->get('/pattr/{id}', [  'as' => 'backend.product.attrval.delete',   'uses' => 'ProductAttributesController@getByProductId']);
});
// 退换货管理
$router->group(['namespace' => 'Change', 'prefix' => 'change'], function () use ($router) {
    $router->get('/', ['uses' => 'ChangeController@index', 'as' => 'backend.change.index']);    //退单列表
    $router->get('/{order_id}', ['uses' => 'ChangeController@show', 'as' => 'backend.change.show']);    //退单详情
    $router->put('/{order_id}', ['uses' => 'ChangeController@update', 'as' => 'backend.change.update']);    //更新退单
    $router->delete('/{order_id}', ['uses' => 'ChangeController@delete', 'as' => 'backend.change.delete']); //删除退单
});
// 举报管理
$router->group(['namespace' => 'Report', 'prefix' => 'report'], function () use ($router) {
    $router->get('/', ['uses' => 'ReportController@index', 'as' => 'backend.report.index']);    //举报列表
    $router->put('/', ['uses' => 'ReportController@update', 'as' => 'backend.report.update']);    //更新举报
    $router->get('/type', ['uses' => 'ReportTypeController@index', 'as' => 'backend.report.type.index']);    //举报类型列表
    $router->post('/type', ['uses' => 'ReportTypeController@store', 'as' => 'backend.report.type.store']);    //举报类型列表
    $router->delete('/type/{id}', ['uses' => 'ReportTypeController@delete', 'as' => 'backend.report.type.delete']); //删除举报类型
});
// 文章分类管理
$router->group(['prefix' => 'article', 'namespace' => 'Article'], function ($router) {
    $router->get('/catelist', ['uses' => 'ArticleCategoryController@index', 'as' => 'backend.article.category.index']);     //文章分类列表
    $router->get('/index_tree', ['uses' => 'ArticleCategoryController@index_tree', 'as' => 'backend.article.category.index']);     //文章分类列表
    $router->get('/category/{id}', ['uses' => 'ArticleCategoryController@show', 'as' => 'backend.article.category.show']);  //文章分类单条查询
    
    $router->put('/category/{id}', ['uses' => 'ArticleCategoryController@update', 'as' => 'backend.article.category.update']);   //更新文章分类
    $router->post('/category', ['uses' => 'ArticleCategoryController@store', 'as' => 'backend.article.category.store']);    //新增文章分类
    $router->delete('/category/{id}', ['uses' => 'ArticleCategoryController@delete', 'as' => 'backend.article.category.delete']);    //新增文章分类
    $router->post('/category/{id}', ['uses' => 'ArticleCategoryController@setShow', 'as' => 'backend.article.category.setShow']);    //新增文章分类
});
//文章管理
$router->group(['namespace' => 'Article', 'prefix' => 'article'], function () use ($router) {
    $router->get('/categorypid', ['uses' => 'ArticleController@category', 'as' => 'backend.article.category']);     //获取文章分类列表

    $router->get('/', ['uses' => 'ArticleController@index', 'as' => 'backend.article.index']);    //文章列表
    $router->put('/{id}', ['uses' => 'ArticleController@update', 'as' => 'backend.article.update']);    //更新文章
    $router->get('/{id}', ['uses' => 'ArticleController@show', 'as' => 'backend.article.show']);    //文章详情
    $router->delete('/{id}', ['uses' => 'ArticleController@delete', 'as' => 'backend.article.delete']);    //文章详情
    $router->post('/', ['uses' => 'ArticleController@store', 'as' => 'backend.article.store']);    //添加文章
    $router->put('/audit/{id}', ['uses' => 'ArticleController@audit', 'as' => 'backend.article.audit']);    //文章展示
    $router->put('/recommend/{id}', ['uses' => 'ArticleController@recommend', 'as' => 'backend.article.recommend']);    //文章推荐
    $router->post('/categoryfid/{id}', ['uses' => 'ArticleController@categoryfid', 'as' => 'backend.article.categoryfid']);     //获取文章子分类列表
    $router->post('/categoryChildren/{id}', ['uses' => 'ArticleController@categoryChildren', 'as' => 'backend.article.categoryChildren']);     //获取文章子分类列表


});
// IM 用户管理
$router->group(['namespace' => 'Im', 'prefix' => 'im'], function () use ($router) {
    $router->get('/',['uses' => 'ImController@index','as' => 'backend.im.index']);// Im 用户列表
    $router->delete('/{id}',['uses' => 'ImController@delete','as' => 'backend.im.delete']);// Im 用户列表
    
});
$router->group(['namespace' => 'Im', 'prefix' => 'record'], function () use ($router) {
    $router->get('/',['uses' => 'ImRecordController@index','as' => 'backend.im.record.index']);// Im聊天记录列表
    $router->get('/{id}',['uses' => 'ImRecordController@show','as' => 'backend.im.record.show']);// Im聊天记录列表
});


// 广告位置管理
$router->group(['prefix' => 'advertisingposition', 'namespace' => 'Advertisement'], function ($router) {
    $router->get('/', ['uses' => 'AdvertisingPositionController@index', 'as' => 'backend.advertisingposition.index']);     //广告位置列表
    $router->get('/{id}', ['uses' => 'AdvertisingPositionController@show', 'as' => 'backend.advertisingposition.show']);  //广告位置单条查询

    $router->put('/{id}', ['uses' => 'AdvertisingPositionController@update', 'as' => 'backend.advertisingposition.update']);   //更新广告位置
    $router->post('/', ['uses' => 'AdvertisingPositionController@store', 'as' => 'backend.advertisingposition.store']);    //新增文章分类
    $router->delete('/{id}', ['uses' => 'AdvertisingPositionController@delete', 'as' => 'backend.advertisingposition.delete']);    //删除广告位置
    $router->post('/{id}', ['uses' => 'AdvertisingPositionController@setShow', 'as' => 'backend.advertisingposition.setShow']);    //新增广告位置
});

//广告管理
$router->group(['namespace' => 'Advertisement', 'prefix' => 'advertisinglist'], function () use ($router) {
    $router->get('/advertisingposition', ['uses' => 'AdvertisingListController@category', 'as' => 'backend.advertisinglist.category']);     //获取广告位置列表

    $router->get('/', ['uses' => 'AdvertisingListController@index', 'as' => 'backend.advertisinglist.index']);    //广告列表
    $router->put('/{id}', ['uses' => 'AdvertisingListController@update', 'as' => 'backend.advertisinglist.update']);    //广告文章
    $router->get('/{id}', ['uses' => 'AdvertisingListController@show', 'as' => 'backend.advertisinglist.show']);    //广告详情
    $router->post('/', ['uses' => 'AdvertisingListController@store', 'as' => 'backend.advertisinglist.store']);    //添加广告
    $router->put('/audit/{id}', ['uses' => 'AdvertisingListController@audit', 'as' => 'backend.advertisinglist.audit']);    //广告展示
    $router->delete('/{id}', ['uses' => 'AdvertisingListController@delete', 'as' => 'backend.advertisinglist.delete']);    //删除广告
    $router->post('/categoryfid/{id}', ['uses' => 'AdvertisingListController@categoryfid', 'as' => 'backend.advertisinglist.categoryfid']);     //获取广告子分类列表


});

// 项目信息管理
$router->group(['prefix' => 'project', 'namespace' => 'Project'], function ($router) {
    $router->get('/', ['uses' => 'ProjectController@index', 'as' => 'backend.project.index']);     //项目信息列表管理
    $router->get('/{id}', ['uses' => 'ProjectController@show', 'as' => 'backend.project.show']);  //项目信息查询
    $router->post('/', ['uses' => 'ProjectController@store', 'as' => 'backend.project.store']);  //项目信息store
    $router->post('/{id}', ['uses' => 'ProjectController@update', 'as' => 'backend.project.update']);  //项目信息update
    $router->post('/setCheckStatus/{id}', ['uses' => 'ProjectController@setCheckStatus', 'as' => 'backend.project.setCheckStatus']);  //项目信息update
    $router->delete('/{id}', ['uses' => 'ProjectController@delete', 'as' => 'backend.project.delete']);  //项目信息delete
});


// custom e CuiLiwu

      